﻿#region License
// (c) Garry McGlennon 2009
// 
// This project is made available under the Microsoft Public License (Ms-PL)
// Code is provided as is and with no warrenty – Use at your own risk
// 
// View the project and the latest code at http://dnpframework.codeplex.com/
// 
// All other rights reserved.
// 
// blog: www.dotNetProfessional.com/blog/
#endregion
#region Using Statements

using System.Configuration;

#endregion

namespace dnp.Framework.Reflection
{
    /// <summary>
    /// This is an ultra simple IoC which will be replaced
    /// once a better framework has been decided upon.
    /// </summary>
    public static class Injector
    {
        public static T Instance<T>()
        {
            string assemblyDetails = ConfigurationManager.AppSettings[typeof(T).FullName];
            if (string.IsNullOrEmpty(assemblyDetails))
                return (T)Assembly.CreateInstance(typeof(T));
            else
            {
                return (T)Assembly.CreateInstanceFromQualifiedName(assemblyDetails);
            }
        }
    }
}